package com.ruoyi.net.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.net.utils.autoIncrement.GlobalIncrementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.net.mapper.BusiL2VpnTunnelStrategyMapper;
import com.ruoyi.net.domain.BusiL2VpnTunnelStrategy;
import com.ruoyi.net.service.IBusiL2VpnTunnelStrategyService;

/**
 * L2_VPN 隧道策略Service业务层处理
 * 
 * @author tony
 * @date 2025-02-17
 */
@Service
public class BusiL2VpnTunnelStrategyServiceImpl implements IBusiL2VpnTunnelStrategyService 
{
    @Autowired
    private BusiL2VpnTunnelStrategyMapper busiL2VpnTunnelStrategyMapper;

    @Autowired
    private GlobalIncrementService globalIncrementService;

    /**
     * 查询L2_VPN 隧道策略
     * 
     * @param id L2_VPN 隧道策略主键
     * @return L2_VPN 隧道策略
     */
    @Override
    public BusiL2VpnTunnelStrategy selectBusiL2VpnTunnelStrategyById(String id)
    {
        return busiL2VpnTunnelStrategyMapper.selectBusiL2VpnTunnelStrategyById(id);
    }

    /**
     * 查询L2_VPN 隧道策略列表
     * 
     * @param busiL2VpnTunnelStrategy L2_VPN 隧道策略
     * @return L2_VPN 隧道策略
     */
    @Override
    public List<BusiL2VpnTunnelStrategy> selectBusiL2VpnTunnelStrategyList(BusiL2VpnTunnelStrategy busiL2VpnTunnelStrategy)
    {
        return busiL2VpnTunnelStrategyMapper.selectBusiL2VpnTunnelStrategyList(busiL2VpnTunnelStrategy);
    }

    /**
     * 新增L2_VPN 隧道策略
     * 
     * @param busiL2VpnTunnelStrategy L2_VPN 隧道策略
     * @return 结果
     */
    @Override
    public int insertBusiL2VpnTunnelStrategy(BusiL2VpnTunnelStrategy busiL2VpnTunnelStrategy)
    {
        String uuid = IdUtils.simpleUUID();
        if (StringUtils.isEmpty(busiL2VpnTunnelStrategy.getId())) {
            busiL2VpnTunnelStrategy.setId(uuid);
        }
        // 生成策略名称 todo 2025-02-17 添加
        busiL2VpnTunnelStrategy.setBusiName("pw-tnl-plcy-" + globalIncrementService.getNextPwTnlPlcyIncrementNumber());
        busiL2VpnTunnelStrategy.setTunnelStrategyMode("TUNNEL-BINGDING");

        busiL2VpnTunnelStrategy.setCreateBy(SecurityUtils.getUsername());
        busiL2VpnTunnelStrategy.setCreateTime(DateUtils.getNowDate());
        busiL2VpnTunnelStrategy.setUpdateBy(SecurityUtils.getUsername());
        busiL2VpnTunnelStrategy.setUpdateTime(DateUtils.getNowDate());
        return busiL2VpnTunnelStrategyMapper.insertBusiL2VpnTunnelStrategy(busiL2VpnTunnelStrategy);
    }

    /**
     * 修改L2_VPN 隧道策略
     * 
     * @param busiL2VpnTunnelStrategy L2_VPN 隧道策略
     * @return 结果
     */
    @Override
    public int updateBusiL2VpnTunnelStrategy(BusiL2VpnTunnelStrategy busiL2VpnTunnelStrategy)
    {
        busiL2VpnTunnelStrategy.setUpdateBy(SecurityUtils.getUsername());
        busiL2VpnTunnelStrategy.setUpdateTime(DateUtils.getNowDate());
        return busiL2VpnTunnelStrategyMapper.updateBusiL2VpnTunnelStrategy(busiL2VpnTunnelStrategy);
    }

    /**
     * 批量删除L2_VPN 隧道策略
     * 
     * @param ids 需要删除的L2_VPN 隧道策略主键
     * @return 结果
     */
    @Override
    public int deleteBusiL2VpnTunnelStrategyByIds(String[] ids)
    {
        return busiL2VpnTunnelStrategyMapper.deleteBusiL2VpnTunnelStrategyByIds(ids);
    }

    /**
     * 删除L2_VPN 隧道策略信息
     * 
     * @param id L2_VPN 隧道策略主键
     * @return 结果
     */
    @Override
    public int deleteBusiL2VpnTunnelStrategyById(String id)
    {
        return busiL2VpnTunnelStrategyMapper.deleteBusiL2VpnTunnelStrategyById(id);
    }
}
